package com.tiancheng.trade.payment.enums;

import com.tiancheng.trade.commom.core.enums.BaseEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 苹果通知类型
 *
 * @author supeicheng
 * @date 2024/3/4
 */
@Getter
@AllArgsConstructor
public enum AppleNotificationTypeEnum implements BaseEnum<String> {

    REFUND("REFUND", "退款成功"),
    REFUND_DECLINED("REFUND_DECLINED", "AppStore拒绝退款"),
    TEST("TEST", "测试通知");

    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<AppleNotificationTypeEnum> found = Arrays.stream(AppleNotificationTypeEnum.values()).filter(c -> c.code.equals(code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }

}
